import matplotlib.pyplot as plt
import numpy as np
# labels='frogs','hogs','热狗','logs'
# sizes=15,20,45,10
# colors='yellowgreen','gold','lightskyblue','lightcoral'
# explode=0,0.1,0,0
# plt.rcParams['font.family']=['STFangsong']
# plt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%',shadow=True,startangle=50)
# plt.axis('equal')
# plt.show()


#查看系统字体库
# from matplotlib import pyplot as plt
# import matplotlib
# a=sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])

# for i in a:
#     print(i)


# import numpy as np 
# import matplotlib.pyplot as plt 
# x = np.arange(1,11) 
# y =  2  * x +  5 
# plt.rcParams['font.family']=['STFangsong']
# plt.title("Matplotlib demo") 
# plt.xlabel("X轴") 
# plt.ylabel("Y轴") 
# plt.plot(x,y,"*b") 
# plt.show()


#正弦波图
# import numpy as np 
# import matplotlib.pyplot as plt 
# # 计算正弦曲线上点的 x 和 y 坐标
# x = np.arange(0,  3  * np.pi,  0.1) 
# y = np.sin(x)
# plt.title("sine wave form")  
# # 使用 matplotlib 来绘制点
# plt.plot(x, y) 
# plt.show()

#条形图
# import matplotlib.pyplot as plt
# plt.rcParams['font.family']=['STFangsong']
# plt.style.use('ggplot')
# print(plt.style.available)

# customers = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO']
# customers_index = range(len(customers))
# sale_amounts = [127, 90, 201, 111, 232]

# fig = plt.figure()
# ax1 = fig.add_subplot(1,1,1)
# ax1.bar(customers_index, sale_amounts, align='center', color='darkblue')
# ax1.xaxis.set_ticks_position('bottom')
# ax1.yaxis.set_ticks_position('left')

# plt.xticks(customers_index, customers, rotation=0, fontsize='small')
# plt.xlabel("顾客名字")
# plt.ylabel('销售总数')
# plt.title('每位顾客的销售数量')

# plt.savefig('bar_plot.png', dpi=400, bbox_inches='tight')
# plt.show()


# 四图合一
# import numpy as np
# import matplotlib.pyplot as plt
 
# # 获取所有的自带样式
# print(plt.style.available)
 
# # 使用自带的样式进行美化
# plt.style.use("ggplot")
 
# fig, axes = plt.subplots(ncols = 2, nrows = 2)
 
# # 四个子图的坐标轴赋予四个对象
# ax1, ax2, ax3, ax4 = axes.ravel()
 
# x, y = np.random.normal(size = (2, 100))
# ax1.plot(x, y, "o")
 
# x = np.arange(1, 10)
# y = np.arange(1, 10)
 
# # plt.rcParams['axes.prop_cycle']获取颜色的字典
# # 会在这个范围内依次循环
# ncolors = len(plt.rcParams['axes.prop_cycle'])
# # print ncolors
# # print plt.rcParams['axes.prop_cycle']
 
# shift = np.linspace(1, 20, ncolors)
# for s in shift:
#     # print s
#     ax2.plot(x, y + s, "-")
 
# x = np.arange(5)
# y1, y2, y3 = np.random.randint(1, 25, size = (3, 5))
# width = 0.25
 
# # 柱状图中要显式的指定颜色
# ax3.bar(x, y1, width, color = "r")
# ax3.bar(x + width, y2, width, color = "g")
# ax3.bar(x + 2 * width, y3, width, color = "y")
 
# for i, color in enumerate(plt.rcParams['axes.prop_cycle']):
#     xy = np.random.normal(size= 2)
#     for c in color.values():
#         ax4.add_patch(plt.Circle(xy, radius = 0.3, color= c))
 
# ax4.axis("equal")
 
# plt.show()



#3D图
# from pylab import *
# from mpl_toolkits.mplot3d import Axes3D

# fig = figure()
# ax = Axes3D(fig)
# X = np.arange(-4, 4, 0.25)
# Y = np.arange(-4, 4, 0.25)
# X, Y = np.meshgrid(X, Y)
# R = np.sqrt(X**2 + Y**2)
# Z = np.sin(R)

# ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot')

# show()

#波浪图
# from pylab import *

# n = 256
# X = np.linspace(-np.pi,np.pi,n,endpoint=True)
# Y = np.sin(2*X)

# plot (X, Y+1, color='blue', alpha=1.00)
# plot (X, Y-1, color='blue', alpha=1.00)
# show()


#散点图
# from pylab import *

# n = 1024
# X = np.random.normal(0,1,n)
# Y = np.random.normal(0,1,n)

# scatter(X,Y)
# show()


#条形图
# from pylab import *

# n = 12
# X = np.arange(n)
# Y1 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n)
# Y2 = (1-X/float(n)) * np.random.uniform(0.5,1.0,n)

# bar(X, +Y1, facecolor='#9999ff', edgecolor='white')
# bar(X, -Y2, facecolor='#ff9999', edgecolor='white')

# for x,y in zip(X,Y1):
#     text(x+0.4, y+0.05, '%.2f' % y, ha='center', va= 'bottom')

# ylim(-1.25,+1.25)
# show()


# 等高线图
# from pylab import *

# def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)

# n = 256
# x = np.linspace(-3,3,n)
# y = np.linspace(-3,3,n)
# X,Y = np.meshgrid(x,y)

# contourf(X, Y, f(X,Y), 8, alpha=.75, cmap='jet')
# C = contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5)
# show()


#灰度图
# from pylab import *

# def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)

# n = 10
# x = np.linspace(-3,3,4*n)
# y = np.linspace(-3,3,3*n)
# X,Y = np.meshgrid(x,y)
# imshow(f(X,Y)), show()


#饼状图
# from pylab import *

# n = 20
# Z = np.random.uniform(0,1,n)
# Z =[1,2,3,4,5,6,7,8,9,10]
# pie(Z), show()


#量场图
# from pylab import *

# n = 8
# X,Y = np.mgrid[0:n,0:n]
# quiver(X,Y), show()



#网格
# from pylab import *

# axes = gca()
# axes.set_xlim(0,4)
# axes.set_ylim(0,3)
# axes.set_xticklabels([])
# axes.set_yticklabels([])
# show()


#多重网格
# from pylab import *

# subplot(2,2,1)
# subplot(2,2,3)
# subplot(2,2,4)

# show()


#极昼图
# from pylab import *

# axes([0,0,1,1])

# N = 20
# theta = np.arange(0.0, 2*np.pi, 2*np.pi/N)
# radii = 10*np.random.rand(N)
# width = np.pi/4*np.random.rand(N)
# bars = bar(theta, radii, width=width, bottom=0.0)

# for r,bar in zip(radii, bars):
#     bar.set_facecolor( cm.jet(r/10.))
#     bar.set_alpha(0.5)

# show()


#手稿图
# import numpy as np
# import matplotlib.pyplot as plt

# eqs = []
# eqs.append((r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$"))
# eqs.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} = -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$"))
# eqs.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$"))
# eqs.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$"))
# eqs.append((r"$F_G = G\frac{m_1m_2}{r^2}$"))


# plt.axes([0.025,0.025,0.95,0.95])

# for i in range(24):
#     index = np.random.randint(0,len(eqs))
#     eq = eqs[index]
#     size = np.random.uniform(12,32)
#     x,y = np.random.uniform(0,1,2)
#     alpha = np.random.uniform(0.25,.75)
#     plt.text(x, y, eq, ha='center', va='center', color="#11557c", alpha=alpha,
#              transform=plt.gca().transAxes, fontsize=size, clip_on=True)

# plt.xticks([]), plt.yticks([])
# # savefig('../figures/text_ex.png',dpi=48)
# plt.show()



	